﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace pcsse.App_Code.entity
{
    public class login
    {
        public DAL.managementTableAdapters.T_LOGINTableAdapter lta = new DAL.managementTableAdapters.T_LOGINTableAdapter();
        //test for svn
        public int LoginByNumber(string number, string password)
        {
            DAL.management.T_LOGINDataTable ldt = lta.GetDataByNumber(number);
            if (ldt.Rows.Count != 1)
            {
                return -1;
            }else{
                string pw = ldt.Rows[0]["PASSWORD"].ToString();
                if (pw != password)
                {
                    return -2;
                }else{
                    return Convert.ToInt32(ldt.Rows[0]["ID"]);
                }
            }
        }
        public int LoginByID(int ID, string password)
        {
            DAL.management.T_LOGINDataTable ldt = lta.GetDataByID(ID);
            if (ldt.Rows.Count != 1)
            {
                return -1;
            }
            else
            {
                string pw = ldt.Rows[0]["PASSWORD"].ToString();
                if (pw != password)
                {
                    return -2;
                }
                else
                {
                    return Convert.ToInt32(ldt.Rows[0]["ID"]);
                }
            }
        }
    }
}
